{% if not environment.web %}
{% extends 'index.html' %}
{% endif %}

{% block body %}
    {% if dao %}
    {% set toota = dao.totali %}
<div class="row">
     <div class="col-xs-12 col-md-12">
        <div class="panel panel-default">
  <div class="panel-heading"><h3>{{dao.operazione}} N° {{dao.numero}} / {{dao.parte|nonone}} del {{utils.dateToString(dao.data_documento)}}</h3></div>
  <div class="panel-body">
           {% if dao.id_cliente %}
<div class="col-sm-12"><span class="label label-default">Cliente</span><h4 style="display:inline;"> {{dao.CLI.ragione_sociale}}</h4>
{% if dao.CLI.email_principale %}
   <span class="glyphicon glyphicon-envelope" style="color:#F47414" aria-hidden="true"></span>
    {% endif %}

</div>
      {% endif %}
      {% if dao.id_fornitore %}
      <div class="col-sm-6"><span class="label label-default">Fornitore</span><h4 style="display:inline;"> {{dao.FORN.ragione_sociale}}</h4>
      {% if dao.FORN.email_principale %}
   <span class="glyphicon glyphicon-envelope" style="color:#F47414" aria-hidden="true"></span>
    {% endif %}
      </div>
      {% endif %}
                  <div class="clearfix"></div>
      <div class='col-sm-12'><hr></div>
      <!--<h3>TOTALI</h3>-->
      <div class="clearfix"></div>
              <div class="col-sm-9">
        <div class="col-sm-3"><span class="label label-danger">IMPO. LORDO</span><h4><strong> {{utils.mNLC(dao._totaleImponibile,2)}}</strong></h4></div>
        <div class="col-sm-3"><span class="label label-danger">SCONTO</span><h4><strong> {{ utils.getStringaSconti(utils.getScontiFromDao(dao.sconti, dao.applicazione_sconti)[0])}}{{ utils.getScontiFromDao(dao.sconti, dao.applicazione_sconti)[1]}}</strong></h4></div>
                      <div class="col-sm-3"><span class="label label-danger">IMPONIBILE</span><h4><strong> {{ utils.mNLC(dao._totaleImponibileScontato,2)}}</strong></h4></div>
                      <div class="col-sm-3"><span class="label label-danger">IMPOSTA</span><h4><strong> {{ utils.mNLC(dao._totaleImpostaScontata,2)}}</strong></h4></div>
                  </div>                   <div class="col-sm-3">

<div style="margin-top:5px;margin-bottom:10px;" class="alert alert-danger col-sm-12 pull-right" role="alert"><h4 style="display:inline;">TOTALE &nbsp;</h4> <h4 class="pull-right" style="display:inline;"><strong><big> {{utils.mNLC(dao._totaleScontato,2)}}</big></strong></h4></div>
  </div>
      <div class="clearfix"></div>
                <div class="panel panel-warning">
            <div class="panel-heading">
              <h3 class="panel-title">RIGHE&nbsp;&nbsp; ({{dao.righe|length}})</h3>
            </div>
            <div class="panel-body">
<div class="table-responsive">
  <table class="table  table-bordered table-striped table-condensed">
   <tr>
        <th>N.</th>
        <th>MAGAZZINO</th>
        <th>CODICE ART</th>
        <th align="center">DESCRIZIONE ARTICOLO</th>
        <th >LISTINO</th>
        <th >Prezzo Lordo</th>
        <th>Sconto</th>
        <th >Prezzo Netto</th>
        <th >Quantita'</th>
        <th >M.plo</th>
        <th >% Iva</th>
        <th>Totale</th>
    </tr>
              {% for riga in dao.righe %}
            <tr >
                <td>{{loop.index}}</td>
                <td>{{(riga.magazzino|nonone)[:15]}}</td>
                <td><b><a href="program:/articoloId={{riga.id_articolo}}">{{riga.codice_articolo}}</a></b></td>
                <td>{{riga.descrizione|nonone}} {{riga.aggiuntalottoindescrizione}}</td>
                <td>{{riga.listino}}</td>
                <td>{{utils.mNLC(riga.valore_unitario_lordo,2)}}</td>
                <td>{{utils.getStringaSconti(utils.getScontiFromDao(riga.sconti)[0])}}</td>
                <td>{{utils.mNLC(riga.valore_unitario_netto,2)}}</td>
                <td>{{riga.quantita}}</td>
                {% if riga.moltiplicatore > 1 %}
                <td>{{riga.multiplo}} ( {{utils.mN(riga.moltiplicatore,2)}} )</td>
                {% else %}
                <td></td>
                {% endif %}
                <td>{{riga.percentuale_iva|int}}</td>
                <td><strong>{{utils.mNLC(( riga.totaleRiga ),2)}}</strong></td>
            </tr>
            {% endfor %}
  </table>
</div>
            </div>
          </div>
            <div style="margin-bottom:5px;" class="clearfix"></div>
        <div class="col-sm-4">
          <div class="panel panel-info">
            <div class="panel-heading">
              <h3 class="panel-title">Pagamenti</h3>
            </div>
            <div class="panel-body">
                <div class="col-sm-12"><span class="label label-info">Pagamento</span> {{dao.pagamento}}</div>
                <div class="col-sm-12"><span class="label label-info">Banca</span> {{dao.banca}}</div>
                <div class="col-sm-12"><span class="label label-info">Aliquota esenzione</span> {{dao.aliquota_iva_esenzione}}</div>
            </div>
          </div>
  </div>
              <div class="col-sm-4">
          <div class="panel panel-info">
            <div class="panel-heading">
              <h3 class="panel-title">Scadenze</h3>
            </div>
            <div class="panel-body">
                {% for scadenza in dao.scadenze %}


                <div class="col-sm-12"><span class="label label-info">Scadenza Pagamento</span> {{ scadenza.pagamento }}</div>
                <div class="col-sm-12"><span class="label label-info">Data Scadenza</span> {{ utils.dateToString(scadenza.data) }}</div>
                <div class="col-sm-12"><span class="label label-info">Importo</span> {{ utils.mNLC(scadenza.importo, 2) }}</div>
                 <div class="col-sm-12"><span class="label label-info">Data Pagamento</span> {{ utils.dateToString(scadenza.data_pagamento) }}</div>
                       {% endfor %}
            </div>
          </div>
  </div>
        <div class="col-sm-4">
          <div class="panel panel-danger">
            <div class="panel-heading">
              <h3 class="panel-title">Totale Contabilita'</h3>
            </div>
            <div class="panel-body">
                <div class="col-sm-12"><span class="label label-danger">Totale Sospeso</span> {{utils.mNLC(dao.totale_sospeso|nonone,2)}}</div>
                <div class="col-sm-12"><span class="label label-danger">Totale Pagato</span> {{utils.mNLC(dao.totale_pagato|nonone,2)}}</div>
            </div>
          </div>
  </div>
       <div style="margin-bottom:5px;" class="clearfix"></div>
              <div class="col-sm-4">
          <div class="panel panel-success">
            <div class="panel-heading">
              <h3 class="panel-title">Aspetto beni</h3>
            </div>
            <div class="panel-body">
                <div class="col-sm-12"><span class="label label-success">Aspetto esteriore beni</span> {{dao.aspetto_esteriore_beni}}</div>
                <div class="col-sm-12"><span class="label label-success">Totale colli</span> {{dao.totale_colli}}</div>
                <div class="col-sm-12"><span class="label label-success">Totale peso</span> {{dao.totale_peso}}</div>
            </div>
          </div>
  </div>
        <div class="col-sm-4">
          <div class="panel panel-success">
            <div class="panel-heading">
              <h3 class="panel-title">Trasporto</h3>
            </div>
            <div class="panel-body">
                <div class="col-sm-12"><span class="label label-success">Causale Trasporto</span> {{dao.causale_trasporto}}</div>
                <div class="col-sm-12"><span class="label label-success">Incaricato trasporto</span> {{dao.incaricato_trasporto}}</div>
                <div class="col-sm-12"><span class="label label-success">Vettore</span> {{dao.ragione_sociale_vettore}}</div>
                <div class="col-sm-12"><span class="label label-success">Inizio trasporto</span> {{utils.dateTimeToString(dao.inizio_trasporto)}}</div>
                <div class="col-sm-12"><span class="label label-success">Fine trasporto</span> {{utils.dateTimeToString(dao.fine_trasporto)}}</div>
            </div>
          </div>
  </div>
        <div class="col-sm-4">
          <div class="panel panel-success">
            <div class="panel-heading">
              <h3 class="panel-title">Destinazione merce</h3>
            </div>
            <div class="panel-body">
                <div class="col-sm-12"><span class="label label-success">Destinazione</span> {{dao.DM.denominazione|nonone}}</div>
                <div class="col-sm-12"><span class="label label-success">Indirizzo</span> {{dao.DM.indirizzo|nonone}}</div>
                <div class="col-sm-12"><span class="label label-success">Località</span> {{dao.DM.localita|nonone}}</div>
                <div class="col-sm-12"><span class="label label-success">CAP</span> {{dao.DM.cap|nonone}}</div>
                <div class="col-sm-12"><span class="label label-success">Provincia</span> {{dao.DM.provincia|nonone}}</div>
            </div>
          </div>
  </div>
       <div class="col-sm-12">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">Note</h3>
            </div>
            <div class="panel-body">
            <div style="margin-bottom:5px;" class="clearfix"></div>
            <div class="col-sm-12"><span class="label label-default">Registro Numerazione</span> {{(dao.registro_numerazione).replace("_"," ").capitalize()}}</div>
      <div class="col-sm-12"><span class="label label-default">Note interne</span> {{dao.note_interne}}</div>
      <div class="col-sm-12"><span class="label label-default">Note pie' pagina</span> {{dao.note_pie_pagina}}</div>
            <div class="col-sm-12"><span class="label label-default">Protocollo</span> {{dao.protocollo}}</div>
{% if dao.merca %}
                <div class="col-sm-12"><span class="label label-default">TOTALE RICARICATO LORDO</span> {{utils.mNLC(dao._totaleRicaricatoLordo,2)}} --
                    ({{utils.mNLC(dao._totaleRicaricatoImponibile,2)}} || {{utils.mNLC(dao._totaleRicaricatoIva,2)}} )</div>
                                             {% endif %}
                </div>
              </div>

  </div> <!-- chiude il panel principale -->
        </div>
    </div>
</div> <!-- chiude il row principale -->

        {% else %}
        <!--<p><img src= "gui/attenzione_48X48.png">ELIMINATO: Niente da visualizzare</p>-->
        <p><img src= "gui/testata_promogest2.png"></p>
        {% endif %}
{% endblock %}
